public class Solution1250 {
    public boolean isGoodArray(int[] nums) {
        int a=nums[0];
        for (int i=1;i<nums.length;i++){
            a=gcd(a,nums[i]);
        }
        return a==1;
    }

    private int gcd(int a, int b) {
        if (a<b){
            int t=a;
            a=b;
            b=t;
        }
        return a%b==0?b:gcd(b,a%b);
    }

    public static void main(String[] args) {
        System.out.println(new Solution1250().isGoodArray(new int[]{12,5,7,23}));
    }
}
